{% extends 'base.html' %}
{% from 'bootstrap/pagination.html' import render_pagination %}
{% from 'macros.html' import user_card, post_card, group_card, column_card with context %}
{% block title %}Flog - Seach: {{ q }}{% endblock %}
{% block search_bar %}
    <form class="form-inline my-2 my-lg-0" action="{{ url_for('main.search', category=category) }}">
        <input type="text" name="q" class="form-control mr-sm-1"
                placeholder="{{ _('Search user, post or group') }}"
            required>
        <input type="hidden" name="category" value="{{ category }}">
        <button class="btn btn-light my-2 my-sm-0" type="submit">
            <span class="bi-search"></span>
        </button>
    </form>
{% endblock %}
{% block page_content %}
    <div class="page-header">
        <h1 class="display-4">Search: <em>{{ q }}</em></h1>
    </div>
    <div class="row">
        <div class="col-md-3">
            <div class="nav nav-pills flex-column" role="tablist" aria-orientation="vertical">
                <a class="nav-item nav-link {% if category == 'post' %}active{% endif %}"
                   href="{{ url_for('.search', q=q, category='post') }}">
                   {{ _("Post") }}
                </a>
                <a class="nav-item nav-link {% if category == 'user' %}active{% endif %}"
                   href="{{ url_for('.search', q=q, category='user') }}">
                   {{ _("User") }}
                </a>
                <a class="nav-item nav-link {% if category == 'group' %}active{% endif %}"
                   href="{{ url_for('.search', q=q, category='group') }}">
                   {{ _("Group") }}
                </a>
                <a class="nav-item nav-link {% if category == 'column' %}active{% endif %}"
                   href="{{ url_for('.search', q=q, category='column') }}">
                    {{ _("Column") }}
                </a>
            </div>
        </div>
        <div class="col-md-9">
            {% if results %}
                <h5>
                    {{ results_count }}
                    {{ ngettext('result', 'results', __num=results|length) }}
                </h5>
                {% for item in results %}
                    {% if category == 'user' %}
                        {{ user_card(item) }}
                    {% elif category == 'group' %}
                        {{ group_card(item) }}
                    {% elif category == 'column' %}
                        {{ column_card(item) }}
                    {% else %}
                        {{ post_card(item) }}
                    {% endif %}
                {% endfor %}
                {{ render_pagination(pagination) }}
            {% else %}
                <h5 class="tip">{{ _("No results") }}</h5>
            {% endif %}
        </div>
    </div>
{% endblock page_content %}